package com.cac.demo.service.itemOutBill;

import com.cac.demo.dao.itemOutBill.ItemInventoryOutbillDao;
import com.cac.demo.dao.itemOutBill.WorkbinMaterialDao;
import com.cac.demo.dao.outBill.ReturnApplyDao;
import com.cac.demo.entity.msWorkbinMaterial.MsWorkbinMaterialDTO;

import com.cac.demo.util.adapter.DaoException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ItemOutBillService {
    @Autowired
    private ItemInventoryOutbillDao itemInventoryOutbillDao;
    @Autowired
    private WorkbinMaterialDao workbinMaterialDao;
    @Autowired
    private ReturnApplyDao returnApplyDao;
    @Transactional
    /*对台账表、物料信息表、退货表进行物料出库数据操作*/
    public Integer updateWmsItemInventory(Map map){
        try{
            itemInventoryOutbillDao.updateWmsItemInventory(map);
            itemInventoryOutbillDao.notReturnQtyUp(map);
            int count = workbinMaterialDao.updateMsWorkbinMaterial(map);
            return count;
        }catch (Exception e){
            throw  new DaoException(e.getMessage(),e);
        }
    }
    /*出库扫码查询*/
    @Transactional
    public List<MsWorkbinMaterialDTO> outBillQuery(HashMap map){
        return workbinMaterialDao.outBillQuery(map);
    }
    /*判断退库是否完成*/
    @Transactional
    public Integer notReturnQtySearch(String wmsReturnApplyId){
        return itemInventoryOutbillDao.notReturnQtySearch(wmsReturnApplyId);
    }
    /*更新退库状态*/
    @Transactional
    public Integer returnStatusUp(String wmsReturnApplyId){
        return itemInventoryOutbillDao.returnStatusUp(wmsReturnApplyId);
    }
}
